package com.gavindon.android

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import com.gavindon.android.adapters.TestRvAdapter

class TestRvActivity : AppCompatActivity() {
    private val rv: RecyclerView by lazy { findViewById(R.id.rv) }
    private val llItem: LinearLayout by lazy { findViewById(R.id.llItem) }
    private val llItem2: LinearLayout by lazy { findViewById(R.id.llItem2) }
    private lateinit var mAdapter: TestRvAdapter
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_test_rv)
        initTab()
    }

    private fun initTab() {
        mAdapter = TestRvAdapter()
        rv.adapter = mAdapter
        rv.requestFocus()
        llItem.setOnClickListener {
            val intent = Intent(this, MainActivity::class.java)
            intent.putExtra(
                "url",
                "http://gstudy.cdn.bcebos.com/gstudy/format/2022/01/25/《图形的旋转》张凤祥下集数学五年级.mp4"
            )
            startActivity(intent)
        }
        llItem2.setOnClickListener {
            val intent = Intent(this, MainActivity::class.java)
            intent.putExtra(
                "url",
                "http://gstudy.cdn.bcebos.com/gstudy/format/2022/01/25/《人与黄土的关系》陈曦下集五年级语文.mp4"
            )
            startActivity(intent)
        }
        mAdapter.setFocusChanged {

        }
        mAdapter.setDownFocusChanged {
            llItem.isFocusable = true
            llItem2.isFocusable = true
            llItem.requestFocus()
        }

    }

}